package com.bw.nav.navigator;

import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.navigation.NavController;
import androidx.navigation.fragment.NavHostFragment;
import androidx.navigation.ui.NavigationUI;

import com.bw.nav.R;
import com.google.android.material.bottomnavigation.BottomNavigationView;

public class NavActivity extends AppCompatActivity {
    private BottomNavigationView basic_bottom;
    private NavController navController;
    private NavHostFragment navHostFragment;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        basic_bottom = findViewById(R.id.basic_bottom);
        navHostFragment = (NavHostFragment) getSupportFragmentManager().findFragmentById(R.id.basic_host_fragment);
        navController = navHostFragment.getNavController();
        FixNavigator fixNavigator =  new FixNavigator(this,
                getSupportFragmentManager(),navHostFragment.getId());
        navController.getNavigatorProvider().addNavigator(fixNavigator);
        navController.setGraph(R.navigation.basic_navgraph);
        NavigationUI.setupWithNavController(basic_bottom,navController);
    }
}
